- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 .ASM 文件,我想在其中调用另一个 .ASM 或 .INC 文件中的过程。
我尝试将以下内容写入我的 main.asm 文件:
INCLUDE file_op.inc
'the emulator is halted.'
; A function to open a file using its name and remember its file_handle
open_file proc
mov ax, 3d00h ; System call to open a file
lea dx, file_name ; name of the file we are opening
int 21h ; system interrupt
mov file_handle, ax ; remember file_handle!!
ret
endp
; A function to read from a file byte by byte using the file_handle we have remembered, and test if we are at the end of the file
read_file proc
mov bx, file_handle
mov cx, 1 ; 1 = number of bytes to read
lea dx, data_from_file ; pointer to reading buffer
mov ah, 3fh ; reading from file via filehandle
int 21h
cmp ax, 0 ; if number of bytes read from file == 0, close file
jz mid_fileclose
ret
endp
; A fucntion to print a character from the file to the screen
data_out proc
mov al, data_from_file ; ASCII code for the last character
mov ah, 09h ; system call for printing strings
lea dx, data_from_file ; address of the string
int 21h ; since al==dx, we print character by character from the file
ret
endp
call open_file
call read_file
call data_out
.model small
.stack 100h
INCLUDE 'file_op.inc'
.data
no_of_lines dw 24 ; number of lines that can be printed within the window, without overwriting old output
printed_lines dw 2 ; number of printed lines we will keep throughout the program, to know when to request user input for moving on to overwriting old output
data_from_file db '.','$' ; a variable where we store characters read from the file
file_handle dw 0 ; file handle using which we read from the file
file_name db "helpDoc.txt", 0 ; name of the file we are reading from
newline db 13,10,'$' ; a variable which we use when we want to print a new line
rrr db '-r' ; a variable against which we compare the user input
size_str = ($ - rrr) ; size of string rrr
argument db 3,?,3 dup(?) ; a variable where we store user input, which defines which mode the program will use
welcome_text db "To print comment lines enter '-r', to print other lines press enter:",13,10,'$' ; a simple welcome text which we display at the start
.code
; A function which prints out a welcome message and promts the user to select the program mode
mode proc
mov ah, 09h ; print out the instruction text
lea dx, welcome_text ; if the user enters '-r', comment lines will be printed
int 21h ; if only enter is pressed, regular lines will be printed
mov ah, 0ah ; system call to get input from the user
lea dx, argument ; storing the input in 'arg' variable
int 21h
mov ah, 09h
lea dx, newline ; print a new line for clear visual effect
int 21h
lea si, [argument + 2] ; load argument (+2 bytes from the address where the string is stored)
lea di, rrr ; load constant rrr = '-r'
mov cx, size_str ; the lenght of the 'arg' variable in bytes
repe cmpsb ; compare the two string until a mismatch occurs, or until cx == 0
jz comments ; if it's not equal, jump to comment, where we print out comment lines from file
ret ; if it's equal, continue to no_comment, where we print out normal lines from file
endp
; Start of the main program
start: mov ax, @data ; load data segment address to ax
mov ds, ax ; move segmet address to ds
mov es, ax ; move segmet address to es
call open_file ; call a procedure to open a file
call mode ; call a procedure to decide which lines we will print from the file
; This is the code section for the no_comment mode, in this mode we print everything except comments ';', '#', '//'.
begin1: call read_file ; read character from file
no_comments: mov al, data_from_file ; move character we have read to al
cmp al, 59 ; compare it against a ';'
je skip_line ; if it's a ';', skip this line from the file and move on to the next one
cmp al, 35 ; compare against a '#'
je skip_line
cmp al, 47
je skip_line ; compare against a '/'
cmp al, 10 ; if it's a newline character, jump to LINE
je new_line1
call data_out ; if none of the above conditions are met, print out the character!
jmp begin1 ; after printing out the character, read from the file again
skip_line: call read_file ; we read from the file, but dont print it on the screen
mov al, data_from_file ; load character we have read into al
cmp al, 10 ; compare it against a newline character
je no_comments ; if there is a match, we are at the end of the line and we start again from no_comment
jmp skip_line ; if we are not at the end of the line we repeat until we are
new_line1: mov ah, 09h ; system call to print a string
lea dx, newline ; print a new line
int 21h
inc printed_lines
mov ax, printed_lines
mov dx, no_of_lines
cmp ax, dx
je wait_for_input1
jmp begin1 ; after we have printed a new line, we read from the file again
mid_fileclose: jmp fileclose ; jump in the read_file procedure was too long so we have a mid jump here
wait_for_input1:mov ah, 07h ; DOS.InputCharacterWithoutEcho
int 21h
mov printed_lines, 0
mov ax, 3
int 10h
jmp begin1
; This is the code section for the COMMENT mode, here we print only comments
begin2: call read_file ; read a character from the file
comments: mov al, data_from_file ; move the character into the al, so we can compare it
cmp al, 59 ; compare against ';'
je new_line2 ; if equal, jump to new_line to print a new line and print until end of line
cmp al, 47 ; compare against '/'
je new_line2
cmp al, 35 ; compare against '#'
je new_line2 ; if none of the conditions above are met, it is not a comment and we dont print anything
skip: call read_file ; read a character from the file, but dont print it
mov al, data_from_file ; move it to al, so we can compare it
cmp al, 10 ; if it is a newline character, we are at the end of a line and we read from the file again
je begin2
cmp al, 59 ; compare against ';'
je comments ; if it's equal, jump to comment a start printing out this line of the file
cmp al, 47 ; compare against '/'
je comments
cmp al, 35 ; compare against '#'
je comments
jmp skip ; if none of the above conditions are met, cycle read through the file
print: call data_out ; print the character on the screen
call read_file ; read another one from the file
mov al, data_from_file ; move it to al, so we can compare it
cmp al, 10 ; if it is a newline character, we are at the end of a line and we read from the file again
je begin2
jmp print ; cycle through the characters in the line of the file until a newline character is found
new_line2: mov ah, 09h ; system call to print a string
lea dx, newline ; print a new line
int 21h
inc printed_lines
mov ax, printed_lines
mov dx, no_of_lines
cmp ax, dx
je wait_for_input2
jmp print ; after we have printed a new line, we start printing out the contents of the comment line from the file
wait_for_input2:mov ah, 07h ; DOS.InputCharacterWithoutEcho
int 21h
mov printed_lines, 0
mov ax, 3
int 10h
jmp begin2
; After we have read everything from the file, we close it and exit the program
fileclose: mov bx, file_handle ; load file handle as an argument for system call
mov ah, 3eh ; close the file using the system call
int 21h
exit: mov ax, 4c00h ; system call to exit the program
int 21h
end start
最佳答案
包含指令 INCLUDE file_op.inc
与将文件的文本直接复制并粘贴到程序集文件中的操作相同,其中 INCLUDE
指令出现。您在 .code
之前包含了一个带有代码的文件已遇到指令。您需要将它包含在 .code
之后.将包含移动到文件中的这一点:
.code
INCLUDE file_op.inc ; <--- Inserted after .code
mode proc
关于assembly - 从另一个文件调用过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55145277/
为了让我的代码几乎完全用 Jquery 编写,我想用 Jquery 重写 AJAX 调用。 这是从网页到 Tomcat servlet 的调用。 我目前情况的类似代码: var http = new
我想使用 JNI 从 Java 调用 C 函数。在 C 函数中,我想创建一个 JVM 并调用一些 Java 对象。当我尝试创建 JVM 时,JNI_CreateJavaVM 返回 -1。 所以,我想知
环顾四周,我发现从 HTML 调用 Javascript 函数的最佳方法是将函数本身放在 HTML 中,而不是外部 Javascript 文件。所以我一直在网上四处寻找,找到了一些简短的教程,我可以根
我有这个组件: import {Component} from 'angular2/core'; import {UserServices} from '../services/UserService
我正在尝试用 C 实现一个简单的 OpenSSL 客户端/服务器模型,并且对 BIO_* 调用的使用感到好奇,与原始 SSL_* 调用相比,它允许一些不错的功能。 我对此比较陌生,所以我可能会完全错误
我正在处理有关异步调用的难题: 一个 JQuery 函数在用户点击时执行,然后调用一个 php 文件来检查用户输入是否与数据库中已有的信息重叠。如果是这样,则应提示用户确认是否要继续或取消,如果他单击
我有以下类(class)。 public Task { public static Task getInstance(String taskName) { return new
嘿,我正在构建一个小游戏,我正在通过制作一个数字 vector 来创建关卡,该数字 vector 通过枚举与 1-4 种颜色相关联。问题是循环(在 Simon::loadChallenge 中)我将颜
我有一个java spring boot api(数据接收器),客户端调用它来保存一些数据。一旦我完成了数据的持久化,我想进行另一个 api 调用(应该处理持久化的数据 - 数据聚合器),它应该自行异
首先,这涉及桌面应用程序而不是 ASP .Net 应用程序。 我已经为我的项目添加了一个 Web 引用,并构建了各种数据对象,例如 PayerInfo、Address 和 CreditCard。但问题
我如何告诉 FAKE 编译 .fs文件使用 fsc ? 解释如何传递参数的奖励积分,如 -a和 -target:dll . 编辑:我应该澄清一下,我正在尝试在没有 MSBuild/xbuild/.sl
我使用下划线模板配置了一个简单的主干模型和 View 。两个单独的 API 使用完全相同的配置。 API 1 按预期工作。 要重现该问题,请注释掉 API 1 的 URL,并取消注释 API 2 的
我不确定什么是更好的做法或更现实的做法。我希望从头开始创建目录系统,但不确定最佳方法是什么。 我想我在需要显示信息时使用对象,例如 info.php?id=100。有这样的代码用于显示 Game.cl
from datetime import timedelta class A: def __abs__(self): return -self class B1(A):
我在操作此生命游戏示例代码中的数组时遇到问题。 情况: “生命游戏”是约翰·康威发明的一种细胞自动化技术。它由一个细胞网格组成,这些细胞可以根据数学规则生存/死亡/繁殖。该网格中的活细胞和死细胞通过
如果我像这样调用 read() 来读取文件: unsigned char buf[512]; memset(buf, 0, sizeof(unsigned char) * 512); int fd;
我用 C 编写了一个简单的服务器,并希望调用它的功能与调用其他 C 守护程序的功能相同(例如使用 ./ftpd start 调用它并使用 ./ftpd stop 关闭该实例)。显然我遇到的问题是我不知
在 dos 中,当我粘贴此命令时它会起作用: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" https://google.
在 dos 中,当我粘贴此命令时它会起作用: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" https://google.
我希望能够从 cmd 在我的 Windows 10 计算机上调用 python3。 我已重新安装 Python3.7 以确保选择“添加到路径”选项,但仍无法调用 python3 并使 CMD 启动 P
我是一名优秀的程序员,十分优秀!