x86-16

8086 Assembly (TASM): Displaying an ASCII character value as HEX

情到浓时终转凉″ 提交于 2019-12-03 00:51:26
** Edited for clarification and "cleaner" code. I'm trying to accept a character from the keyboard (any character) and convert it's ASCII value to hex, then display it. I know how to convert from base 10 to hex, but just to make sure I'm not using incorrect terminology: If I enter "c" in as my ASCII value, it's decimal value is 63. 63 divided by 16 (hex is base 16) = 3.9375. Save the quotient of 3 for later. Remainder * base (.9375 * 16) = 15. 15 is Hex character "F". Quotient divided by base (3 / 16) = 0.1875. Quotient is zero, so this is the last step in conversion. Remainder * base (.1875 *

Assembly offset calculation rule

人盡茶涼 提交于 2019-12-02 19:59:14
问题 So... the rule of offset calculation states in my course book that: offset = [bp] + [bx] + [di|si] + CONST (any part is optional, but atleast one is required) But reading on the internet i found the rule as : offset = [bp|bx] + [di|si] + CONST Which one is it? And why? (In my opinion the first should be also valid since bx could contain an arbitrary value like (1..F), but i tend to belive I am wrong and there must be a BX or BP) 回答1: The "internet rule" is correct. You can have 1 base

INT 21h does not print

拥有回忆 提交于 2019-12-02 17:49:12
问题 I wonder why this procedure does not print: print: push ax push bx push dx mov ah, 02h ciclo: mov al, [si] int 21h inc si loop ciclo pop dx pop bx pop ax ret According to here, calling INT 21h while AH is 2, prints on stdout the ASCII code contained in AL . While debugging I found nothing... 回答1: It will print the character in DL (see this reference). For example, if DL contains the decimal value 65, it will print the character A (since 65 is the ASCII code for 'A') 来源: https://stackoverflow

BCD to ASCII conversion

血红的双手。 提交于 2019-12-02 17:04:34
问题 I know that every 4 bit in BCD is one digit in decimal, but I have a problem, for example when I want to print a BCD value stored in CH I do this : add ch, 30h but, when the value is 12, it prints "C", I want to print "12". How can I do operations on 4 bit of data? 回答1: mov al,ch ; if ch has 12h aam ; ax will now be 0102h or ax,3030h ; converting into ascii - ax will now become 3132h ; you can now print the value in ax mov cx,ax mov dl,ch ; to print on screen mov ah,02h int 21h mov dl,cl int

Issues writing to file in assembly

狂风中的少年 提交于 2019-12-02 14:24:34
I am trying to write a simple program in assembly in which I open an existing file and I write a message in it, a message which I define in my data segment. The problem occurs when I want to write to my file. The AX register will contain 5 after I try writing to it, and the Norton Expert Guide says that is an 'Access denied' error code. Any ideas on what I'm doing wrong? Sorry if this question is pretty easy, I'm just trying to learn some assembly for an upcoming test. I am using TASM to compile my code. The file in which I want to write exists(hence the no error when I open it) and it's empty

Assembly code skipping a line?

*爱你&永不变心* 提交于 2019-12-02 13:23:55
Why is my assembly code skipping a line? It keeps skipping the line mov AX,A org 100h count equ 2 A DW 5 B DW 6 Y0 DW ? Y1 DW ? mov AX,A add AX,B sub AX,count mov Y0,AX mov BX,B neg BX add BX,count mov Y1,BX ret Cody Gray Let's see what code bytes these instruction mnemonics would assemble to: org 100h count equ 2 05 00 A DW 5 06 00 B DW 6 00 00 Y0 DW ? 00 00 Y1 DW ? A1 00 01 mov AX,A ;NASM "mov ax, [A]" 03 06 02 01 add AX,B ;NASM "add ax, [B]" 83 E8 02 sub AX,count ... The code bytes are on the left; the instruction mnemonics (the part you feed to the assembler) are on the right. All looks

INT 21h does not print

房东的猫 提交于 2019-12-02 11:31:44
I wonder why this procedure does not print: print: push ax push bx push dx mov ah, 02h ciclo: mov al, [si] int 21h inc si loop ciclo pop dx pop bx pop ax ret According to here , calling INT 21h while AH is 2, prints on stdout the ASCII code contained in AL . While debugging I found nothing... It will print the character in DL (see this reference ). For example, if DL contains the decimal value 65, it will print the character A (since 65 is the ASCII code for 'A') 来源: https://stackoverflow.com/questions/16479762/int-21h-does-not-print

What does DX + 2 mean in mov ah,9 int 21h?

自闭症网瘾萝莉.ら 提交于 2019-12-02 11:04:54
问题 mov dx, offset buffer mov ah, 0ah int 21h jmp print buffer db 10,?, 10 dup(' ') print: xor bx, bx mov bl, buffer[1] mov buffer[bx+2], '$' mov dx, offset buffer + 2 mov ah, 9 int 21h I know buffer[bx+2] stands for '$', but offset buffer +2 in mov ah,9 stands for what? They said, "Start printing from address DS:DX + 2 ". From address ds:dx +2 . 回答1: When a string is captured from keyboard with int 21h, ah=0Ah, the string has next structure: As you can see, the first two bytes are control, the

Override default INT 9h

你说的曾经没有我的故事 提交于 2019-12-02 10:00:57
I'm trying to override the default interruption when a key is pressed. Here is my code : I don't understand why it doesn't work, it works with others INT numbers (43h for example) mov al,9h mov ah,25h mov bx,seg int9h mov ds,bx mov dx,offset int9h int 21h (Where int9h is a label in my code) Does anyone know how to hook the interruption when a key is pressed ? Thanks ! EDIT: mov ax,2509h mov dx,offset int9h int 21h int9h PROC ;do some stuff IRET int9h ENDP I'll try and answer this again - in a somewhat long-winded fashion. Before Windows became prevalent, DOS ruled the computer. In order to

Assembly offset calculation rule

天大地大妈咪最大 提交于 2019-12-02 08:42:10
So... the rule of offset calculation states in my course book that: offset = [bp] + [bx] + [di|si] + CONST (any part is optional, but atleast one is required) But reading on the internet i found the rule as : offset = [bp|bx] + [di|si] + CONST Which one is it? And why? (In my opinion the first should be also valid since bx could contain an arbitrary value like (1..F), but i tend to belive I am wrong and there must be a BX or BP) The "internet rule" is correct. You can have 1 base register ( bp or bx ) and 1 index register ( si or di ). You can't have bp + bx or si + di at the same time. See